<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->display();
    }
 
    // PC 登陆检查
    public function chklogin($username='',$userpwd=''){
    	$user=M('admins');
    	$where=array('username'=>$username,'pwd'=>md5($userpwd));
    	$row=$user->where($where)->find();

    	if($row){
    		$_SESSION['username']=$row['username'];
    		$_SESSION['userid']=$row['id'];
    		echo '1';
    	}
    	else{
    		echo '0';
    	}
    }

    // PC 退出登陆
    public function logout(){
        $_SESSION=array();
        setcookie('PHPSESSIONID','',time-3600,'/');
        session_destroy();
        echo '1';
    }

    // PC 获取 树形菜单
    public function getNav($id=0){
        $nav=M('menu');
        $row=$nav->where("nid={$id}")->select();  
        // $rows=json_encode($row);
        // echo '['.$rows.']';
        $this->ajaxReturn($row);
    }

}